<!-- 网站信息 -->
<template>
    <div class="user-setup">
        <el-card shadow="never" class="!border-none">
            <div class="font-medium mb-7">基本设置</div>
            <el-form ref="formRef" :model="formData" label-width="140px">
                <el-form-item label="每日提现次数">
                    <el-input v-model="formData.day_withdraw_num" style="width: 150px;" />
                </el-form-item>
                <el-form-item label="单次提现最大金额">
                    <el-input v-model="formData.withdraw_money_max" style="width: 150px;" />
                </el-form-item>
            </el-form>
        </el-card>

        <footer-btns v-perms="['setting.user.user/setConfig']">
            <el-button type="primary" @click="handleSubmit">保存</el-button>
        </footer-btns>
    </div>
</template>

<script lang="ts" setup name="userSetup">
import { getWithdrawConfig, setWithdrawConfig } from '@/api/boom_withdraw'

// 表单数据
const formData = reactive({
    day_withdraw_num: '', // 用户默认头像
    withdraw_money_max: ''
})

// 获取用户设置数据
const getData = async () => {
    try {
        const data = await getWithdrawConfig()
        for (const key in formData) {
            //@ts-ignore
            formData[key] = data[key]
        }
    } catch (error) {
        console.log('获取=>', error)
    }
}

// 保存用户设置数据
const handleSubmit = async () => {
    try {
        await setWithdrawConfig(formData)
        getData()
    } catch (error) {
        console.log('保存=>', error)
    }
}

getData()
</script>

<style lang="scss" scoped></style>
